package com.tangruojie;

import com.tangruojie.dao.BookDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AppForLifeCycle {

    public static void main(String[] args) {
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        BookDao bookDao = (BookDao) applicationContext.getBean("bookDao");
        bookDao.save();
        /**
         * 注册关闭钩子，容器关闭时，会执行销毁方法
         */
        applicationContext.registerShutdownHook();
//        applicationContext.close();
    }

}
